package com.artPreter.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//应为类型要求为WebMvcConfigurer，所以我们实现其接口
//可以使用自定义类扩展MVC的功能
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("pc/threeInOne.html").setViewName("index");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        String path = "D:\\java\\";//"/tools/images/";//"E:/视频制作/图片/";
        if(true){

            //registry.addResourceHandler("/uploads/**").addResourceLocations("file:" + path);
            registry.addResourceHandler("/prod-api/uploads/**").addResourceLocations("file:" +  System.getProperty("user.dir")+"/home/artUpLoads/");
            registry.addResourceHandler("/dev-api/uploads/**").addResourceLocations("file:" +  System.getProperty("user.dir")+"/home/artUpLoads/");
        }else{
            registry.addResourceHandler("/uploads/**").addResourceLocations("file:" +  "/home/artUpLoads/");
        }

    }



}